package com.tulingxueyuan.mall.modules.oms.service.impl;

import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tulingxueyuan.mall.modules.oms.model.OmsOrderReturnReason;
import com.tulingxueyuan.mall.modules.oms.mapper.OmsOrderReturnReasonMapper;
import com.tulingxueyuan.mall.modules.oms.service.OmsOrderReturnReasonService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tulingxueyuan.mall.modules.pms.model.PmsProductCategory;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * <p>
 * 退货原因表 服务实现类
 * </p>
 *
 * @author zhaofuhao
 * @since 2022-03-03
 */
@Service
public class OmsOrderReturnReasonServiceImpl extends ServiceImpl<OmsOrderReturnReasonMapper, OmsOrderReturnReason> implements OmsOrderReturnReasonService {
    /**
     * 查询退货原因
     * @param pageSize
     * @param pageNum
     * @return
     */
    @Override
    public Page list(Integer pageSize, Integer pageNum) {
        Page page = new Page(pageNum, pageSize);
        return  this.page(page);

    }

    /**
     * 添加退货原因
     * @param omsOrderReturnReason
     * @return
     */
    @Override
    public boolean add(OmsOrderReturnReason omsOrderReturnReason) {
        //获取当前系统时间
        omsOrderReturnReason.setCreateTime(new Date());
        return this.save(omsOrderReturnReason);
    }


    /**
     * 修改是否可用
     * @param ids
     * @param status
     * @return
     */
    @Override
    public boolean updateStatus(List<Long> ids, Integer status) {
        UpdateWrapper<OmsOrderReturnReason> OmsOrderReturnReasonUpdateWrapper = new UpdateWrapper<>();
        //需要更新的列
        OmsOrderReturnReasonUpdateWrapper.lambda().set(OmsOrderReturnReason::getStatus,status)
                .in(OmsOrderReturnReason::getId,ids);
        return   this.update(OmsOrderReturnReasonUpdateWrapper);
    }
}
